package com.vcms.cms.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Channel entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "channel", catalog = "vcms_0.1")
public class Channel implements java.io.Serializable {
	// Fields

	private Integer channelId;
	private String channelPath;
	private Integer priority;
	private Boolean hasContent;
	private Boolean isDisplay;
	private Model model;
	private Site site;
	private Channel parentChannel;
	private Boolean isActivated;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "siteId")
	public Site getSite() {
		return site;
	}

	public void setSite(Site site) {
		this.site = site;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parentId")
	public Channel getParentChannel() {
		return parentChannel;
	}

	public void setParentChannel(Channel parentChannel) {
		this.parentChannel = parentChannel;
	}

	public Boolean getIsActivated() {
		return isActivated;
	}

	public void setIsActivated(Boolean isActivated) {
		this.isActivated = isActivated;
	}

	private Set<UserGroup> viewUserGroups = new HashSet<UserGroup>(0);
	private Set<UserGroup> contributeUserGroups = new HashSet<UserGroup>(0);
	private Set<User> users = new HashSet<User>(0);
	private Set<ChannelAttr> channelAttrs = new HashSet<ChannelAttr>(0);
	private Set<ChannelContent> channelContents = new HashSet<ChannelContent>(0);
	private Set<ChannelTxt> channelTxts = new HashSet<ChannelTxt>(0);
	private Set<Topic> topics = new HashSet<Topic>(0);
	private Set<Channel> channelChildrens = new HashSet<Channel>(0);

	// Constructors

	/** default constructor */
	public Channel() {
	}

	/** full constructor */
	public Channel(String channelPath, Integer lft, Integer rgt,
			Integer priority, Boolean hasContent, Boolean isDisplay,
			Set<UserGroup> viewUserGroups, Set<UserGroup> contributeUserGroups,
			Set<User> users, Set<ChannelAttr> channelAttrs,
			Set<ChannelContent> channelContents, Set<Model> models,
			Set<ChannelTxt> channelTxts, Set<Topic> topics) {
		this.channelPath = channelPath;
		this.priority = priority;
		this.hasContent = hasContent;
		this.isDisplay = isDisplay;
		this.viewUserGroups = viewUserGroups;
		this.contributeUserGroups = contributeUserGroups;
		this.users = users;
		this.channelAttrs = channelAttrs;
		this.channelContents = channelContents;
		this.channelTxts = channelTxts;
		this.topics = topics;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "channelId", unique = true, nullable = false)
	public Integer getChannelId() {
		return this.channelId;
	}

	public void setChannelId(Integer channelId) {
		this.channelId = channelId;
	}

	@Column(name = "channelPath", length = 300)
	public String getChannelPath() {
		return this.channelPath;
	}

	public void setChannelPath(String channelPath) {
		this.channelPath = channelPath;
	}

	@Column(name = "priority")
	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@Column(name = "hasContent")
	public Boolean getHasContent() {
		return this.hasContent;
	}

	public void setHasContent(Boolean hasContent) {
		this.hasContent = hasContent;
	}

	@Column(name = "isDisplay")
	public Boolean getIsDisplay() {
		return this.isDisplay;
	}

	public void setIsDisplay(Boolean isDisplay) {
		this.isDisplay = isDisplay;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "viewChannels")
	public Set<UserGroup> getViewUserGroups() {
		return viewUserGroups;
	}

	public void setViewUserGroups(Set<UserGroup> viewUserGroups) {
		this.viewUserGroups = viewUserGroups;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "contributeChannels")
	public Set<UserGroup> getContributeUserGroups() {
		return contributeUserGroups;
	}

	public void setContributeUserGroups(Set<UserGroup> contributeUserGroups) {
		this.contributeUserGroups = contributeUserGroups;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "channels")
	public Set<User> getUsers() {
		return this.users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "channel")
	public Set<ChannelAttr> getChannelAttrs() {
		return this.channelAttrs;
	}

	public void setChannelAttrs(Set<ChannelAttr> channelAttrs) {
		this.channelAttrs = channelAttrs;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "channel")
	public Set<ChannelContent> getChannelContents() {
		return this.channelContents;
	}

	public void setChannelContents(Set<ChannelContent> channelContents) {
		this.channelContents = channelContents;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "channel")
	public Set<ChannelTxt> getChannelTxts() {
		return this.channelTxts;
	}

	public void setChannelTxts(Set<ChannelTxt> channelTxts) {
		this.channelTxts = channelTxts;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "channel")
	public Set<Topic> getTopics() {
		return this.topics;
	}

	public void setTopics(Set<Topic> topics) {
		this.topics = topics;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "modelId")
	public Model getModel() {
		return model;
	}

	public void setModel(Model model) {
		this.model = model;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parentChannel")
	public Set<Channel> getChannelChildrens() {
		return channelChildrens;
	}

	public void setChannelChildrens(Set<Channel> channelChildrens) {
		this.channelChildrens = channelChildrens;
	}

}

